/*
 * Copyright 2016 Yan Zhenjie
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.mingmen.canting.activity;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.mingmen.canting.R;
import com.mingmen.canting.adapter.FileerFangqiAdapter;
import com.mingmen.canting.caigourenyuan.CaiGouRenDaiListragment;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import de.greenrobot.event.EventBus;


/**
 * <p>
 * ListView形式的侧滑菜单，支持横向和竖向的。
 * </p>
 * Created by Yan Zhenjie on 2016/7/27.
 */
public class FilterCompareActivity extends Activity {
    @BindView(R.id.img_return)
    ImageView imgReturn;

    @BindView(R.id.layout_close)
    LinearLayout layoutClose;


    String string;

    List<String> dingdan = new ArrayList<>();

    String subPriceLine;
    @BindView(R.id.arriveDate)
    TextView arriveTextDate;
    @BindView(R.id.price)
    TextView text_price;
    @BindView(R.id.text_amount)
    TextView text_amount;
    @BindView(R.id.text_total)
    TextView text_total;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity__filtercompare);
        EventBus.getDefault().register(this);
        ButterKnife.bind(this);

        DividerItemDecoration divider = new DividerItemDecoration(this, DividerItemDecoration.VERTICAL);
        divider.setDrawable(ContextCompat.getDrawable(this, R.drawable.custom_divider));
        subPriceLine = getIntent().getStringExtra("subPriceLine");
        JSONArray jsonArray = JSONArray.parseArray(subPriceLine);
        String mamount = "";
        String mprice = "";
        for (int i = 0; i < jsonArray.size(); i++) {
            JSONObject jsonObject = jsonArray.getJSONObject(i);
            double amount = jsonObject.getDouble("amount");
            String arriveDate = jsonObject.getString("arriveDate");
            double price = jsonObject.getDouble("price");
            String supplierName = jsonObject.getString("supplierName");

            DecimalFormat format = new DecimalFormat("");
/*            String str= format.format(jsonObject.getString("amount"));
            String str1= format.format(jsonObject.getString("price"));
            mamount= str;*/
            arriveTextDate.setText(arriveDate);
//            mprice = str1;
//            text_price.setText(price);
            text_price.setText(price+"");
            text_amount.setText("数量: "+amount);
//            int totalPrice=amount*price;

//            text_total.setText(totalPrice+"");

            Log.d("amount", amount + "");
            Log.d("arriveDate", arriveDate);
            Log.d("price", price + "");
            Log.d("supplierName", supplierName);
        }

/*        int a=Integer.valueOf(mamount);
        int b=Integer.valueOf(mprice);

        Log.d("a", a+b+"");*/
    }


    @OnClick({R.id.img_return, R.id.layout_close})
    public void onViewClicked(View view) {
        Intent intent;
        switch (view.getId()) {

            case R.id.img_return:
            case R.id.layout_close:

                finish();

                break;


        }
    }

    public void onEventMainThread(Integer type) {

    }


}